home *** CD-ROM | disk | FTP | other *** search
/ Mac Cube 4: Multimedia Applications / MacCube Volume 4: Multimedia Applications.iso / Graphics / NIH Image Folder / Macros / Fun and Games < prev    next >
Text File  |  1993-07-30  |  3KB  |  129 lines

  1. macro 'Random Ovals';
  2. var
  3.   PicWidth,PicHeight,hloc,vloc,width,height:real;
  4. begin
  5.   SaveState;
  6.   SetPalette('Spectrum');
  7.   MakeNewWindow('Random Ovals');
  8.   GetPicSize(PicWidth,PicHeight);
  9.   repeat
  10.     hloc:=width*random;
  11.     vloc:=height*random;
  12.     width:=(PicWidth-hloc)*random;
  13.     height:=(PicHeight-vloc)*random;
  14.     MakeOvalRoi(hloc,vloc,width,height);
  15.     SetForeground(255*random);
  16.     fill;
  17.   until Button;
  18.   KillRoi;
  19.   RestoreState;
  20. end;
  21.  
  22.  
  23. macro 'Draw Ball';
  24. var
  25.   width,height,n,i,color,diam,nSteps:integer;
  26. begin
  27.   SaveState;
  28.   nSteps:=64;
  29.   SetPalette('Spectrum');
  30.   SetBackground(255); {Black}
  31.   MakeNewWindow('Ball');
  32.   GetPicSize(Width,Height);
  33.   if width>height
  34.     then diam:=height
  35.     else diam:=width;
  36.   color:=1;
  37.   MakeOvalRoi((width-diam)/2,(height-diam)/2,diam,diam);
  38.   for i:=1 to nSteps do begin
  39.     InsetRoi(round(diam/(3*nSteps)));
  40.     SetForeground(color);
  41.     fill;
  42.     color:=color+round(256/nSteps);
  43.     if color>254 then color:=254;
  44.   end;
  45.   KillRoi;
  46.   RestoreState;
  47. end;
  48.  
  49.  
  50. macro 'Speckle Paint [S]';
  51. var
  52.   x,y,ranx,rany,MaxSpeckSize,size,Spread:integer;
  53. begin
  54.   RequiresVersion(1.48);
  55.   SetCursor('Cross');
  56.   Spread:=50;
  57.   MaxSpeckSize:=5;
  58.   KillRoi;
  59.   repeat
  60.     GetMouse(x,y);
  61.     if button then begin
  62.       ranx:=x+Spread*(Random-0.5);
  63.       rany:=y+Spread*(Random-0.5);
  64.       size:=(MaxSpeckSize-2)*random+2;
  65.       MakeOvalRoi(ranx-size,rany-size,size*2,size*2);
  66.       SetForeground(Random*254+1)
  67.       fill;
  68.     end;
  69.   until (x<0) or (y<0);
  70.   KillRoi;
  71. end;
  72.  
  73.  
  74. macro 'Random Color Boxes';
  75. var
  76.   n,PicWidth,PicHeight,hloc,vloc,size:integer;
  77. begin
  78.   SaveState;
  79.   n:=24;
  80.   GetPicSize(PicWidth,PicHeight);
  81.   if PicWidth=0 then begin
  82.     PutMessage
  83.     ('This macro needs an opened image, preferably in color, to operate on.');
  84.     Exit;
  85.   end;
  86.   size:=round(PicWidth/n);
  87.   repeat
  88.     hloc:=((PicWidth*random) div size)*size;
  89.     vloc:=((PicHeight*random) div size)*size;
  90.     MakeRoi(hloc,vloc,size,size);
  91.     SetForeground(255*random);
  92.     fill;
  93.     {Invert;}
  94.   until Button;
  95.   KillRoi;
  96.   RestoreState;
  97. end;
  98.  
  99.  
  100. macro 'Random LUT Colors [C]';
  101. var
  102.   i,colors,entries,first,last,r,g,b:integer;
  103. begin
  104.   RequiresVersion(1.48);
  105.   SetCursor('Watch');
  106.   colors:=25;;
  107.   entries:=256/colors;
  108.   if entries>256 then entries:=256;
  109.   repeat 
  110.     first:=random*255;
  111.     last:=first+entries-1;
  112.     if last>255 then last:=255;
  113.     r:=random*255;
  114.     g:=random*255;
  115.     b:=random*255;
  116.     for i:=first to last do begin
  117.       RedLUT[i]:=r;
  118.       GreenLUT[i]:=g;
  119.       BlueLUT[i]:=b;
  120.     end;
  121.     UpdateLUT;
  122.   until button;
  123. end;
  124.  
  125.  
  126.  
  127.  
  128.  
  129.